<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="Cinema Information System">
        <title><?php echo $cinema_info->name . ': ' . (isset($page_title) ? $page_title : "Page"); ?></title>
        
        <?php echo Asset::js('jquery-1.11.0.min.js'); ?>
        
        <?php echo Asset::js('jquery-ui-1.10.4.min.js'); ?>
        <?php echo Asset::css('jquery-ui-1.10.4.min.css'); ?>
        
        <?php echo Asset::js('jquery.validate.min.js'); ?>
        <?php echo Asset::js('localization/messages_' . $language . '.js'); ?>
        
        <?php echo Asset::js('bootstrap.min.js'); ?>
        <?php echo Asset::css('bootstrap.min.css'); ?>
        
        <?php echo Asset::css('jquery-ui.css'); ?>
        <?php echo Asset::css('style.css'); ?>
    </head>
    <body>
        <div class="container">
                <div class="row clearfix">
                        <div class="col-md-12 column">
                            <nav class="navbar navbar-default" role="navigation">
				<div class="navbar-header">
					 <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button> <a class="navbar-brand" href="/"><?php echo $cinema_info->name; ?></a>
				</div>
				
				<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                                        <span class="middle-align">
                                            <?php echo __('LANGUAGE')?>: 
                                            <a href="/user/setlanguage/lv"><img src="/assets/img/lv_flag.png" alt="Latvian flag" title="Latviešu valoda" /></a> | 
                                            <a href="/user/setlanguage/en"><img src="/assets/img/en_flag.png" alt="Great Britain flag" title="English langauge" /></a>
                                        </span>   
					<div class="navbar-form navbar-right" role="search">
                                            <?php echo Form::open(array('method' => 'GET', 'action' => '/search/title/')); ?>
						<div class="form-group">
                                                    <?php echo Form::input('phrase', Input::get('phrase') ? Input::get('phrase') : '', array("class"=>"form-control") ); ?>
						</div>
                                                <?php echo Form::submit('', __('SEARCH'), array("class"=>"btn btn-default") ); ?> 
                                            <?php echo Form::close(); ?>
					</div>
				</div>
                            </nav>
                        </div>
                </div>
                <div class="row clearfix">
                        <div class="col-md-3 column navigation-top-margin">
                                <div class="panel panel-default">
                                        <div class="panel-heading">
                                                <h3 class="panel-title">
                                                        <?php echo __("USER_PANEL"); ?>
                                                </h3>
                                        </div>
                                        <div class="panel-body">
<?php
    if (Auth::check()) {
        echo '<p>
        '. __('GREETING') . ' '. Auth::get_screen_name() .'<br>
        <a href="/user/profile/">'. __('USER_PROFILE') .'</a><br>
        <a href="/user/myorders/">'. __('MY_ORDERS') .'</a><br>
        <a href="/user/logout/">'. __('EXIT') .'</a><br>
        </p>';
        
        if(Auth::member(100)) {
            echo '<hr><p>
                '. __('ADMIN_OPTIONS') .':<br>
                <a href="/movie/add/">'. __('ADD_MOVIE') .'</a><br>
                <a href="/show/view/">'. __('MOVIE_SHOWS') .'</a><br>
                <a href="/auditorium/list/">'. __('AUDITORIUMS') .'</a><br>
                <a href="/genre/manage/">'. __('MOVIE_GENRES') .'</a><br>
                <a href="/cinema/info/">'. __('CINEMA_INFO') .'</a><br>
            
            </p>';
                
        }
    } else {
        echo '<p>
        '. __('GREETINGS_GUEST') .'<br>
        <span class="glyphicon glyphicon-log-in"></span>&nbsp;&nbsp;<a href="/user/login/">'. __('LOGIN') .'</a><br>
        <span class="glyphicon glyphicon-registration-mark"></span>&nbsp;&nbsp;<a href="/user/register/">'. __('REGISTER') .'</a>
        </p>';
    }
?>
                                        </div>
                                </div>
                                <div class="panel panel-default">
                                        <div class="panel-heading">
                                                <h3 class="panel-title">
                                                        <?php echo __('MOVIES') ?>
                                                </h3>
                                        </div>
                                        <div class="panel-body">
                                                <span class="glyphicon glyphicon-arrow-right"></span>&nbsp;&nbsp;<a href="/search/"><?php echo __('UPCOMING_SHOWS') ?></a><br>
                                                <span class="glyphicon glyphicon-search"></span>&nbsp;&nbsp;<a href="/search/detailed"><?php echo __('SEARCH_SHOWS') ?></a><hr>
                                                <?php echo __('GENRES') ?>:
                                                <ul>
                                                    <?php 
                                                        if(isset($genres)) {
                                                            foreach($genres as $genre) {
                                                                echo '<li><a href="/genre/view/'. $genre->id .'">' . ($language == 'lv' ? $genre->genre_lv : $genre->genre_en) . '</a></li>';
                                                            }   
                                                        }
                                                    ?>
                                                </ul>
                                        </div>
                                </div>
                        </div>
                        <div class="col-md-9 column">
                            <?php if(Session::get_flash('error')): ?> 
                                <div class="alert alert-warning alert-dismissable">
                                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                        <h4><strong><?php echo __('ERROR') ?></strong></h4>
                                        <p>
                                            <?php echo implode('</p><p>', e((array) Session::get_flash('error'))); ?>
                                        </p>
                                </div>
                            <?php endif; ?>
                            
                            <?php if(Session::get_flash('success')): ?> 
                                <div class="alert alert-success alert-dismissable">
                                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                        <h4><strong><?php echo __('SUCCESS') ?></strong></h4>
                                        <p>
                                            <?php echo implode('</p><p>', e((array) Session::get_flash('success'))); ?>
                                        </p>
                                </div>
                            <?php endif; ?>
                                <div class="row">
                                    <?php 
                                        if(isset($page_content)) {
                                            echo $page_content;
                                        }
                                    ?>
                                </div>
                        </div>
                </div>
                <div class="row clearfix">
                        <div class="col-md-12 column">
                            <hr>
                            <?php echo __('CINEMA') ?> "<strong><?php echo $cinema_info->name; ?></strong>" | <?php echo $cinema_info->slogan; ?><br>
                            <address><?php echo __('ADDRESS') ?>: <strong><?php echo $cinema_info->address; ?></strong></address>
                        </div>
                </div>
        </div>  
        
        <?php echo Asset::js('validations.js'); ?>
        
        <?php echo Asset::js('script.js'); ?>
        <?php if(isset($page_custom_scripts)) {        
                foreach($page_custom_scripts as $script) {
                    echo Asset::js($script);
                }
            }
        ?>
    </body>
</html>